package com.qf.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.qf.entity.Goods;
import com.qf.feign.api.IGoodsService;
import com.qf.resp.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private IGoodsService goodsService;

    @RequestMapping("/getGoodsPage")
    public String getGoodsPage(Page<Goods> page,Model model){
        page = goodsService.getGoodsPage(page);
        model.addAttribute("page",page);
        return "goods/goodsList";
    };

    @RequestMapping("/addGoods")
    @ResponseBody
    public ResultEntity addGoods(Goods goods){
        return goodsService.addGoods(goods);
    }
}
